package com.knife.cachev2.controller;

import com.knife.cachev2.service.KnifeCacheV2Service;
import com.knife.common.utils.Results;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lth
 * @created 2025年08月01日 星期五 14:12
 */
@RestController("v1.KnifeCacheV2Controller")
@RequestMapping("/v2/cache")
public class KnifeCacheV2Controller {

    @Resource
    private KnifeCacheV2Service knifeCacheV2Service;

    @GetMapping("/reload")
    public ResponseEntity<String> reloadCache() {
        knifeCacheV2Service.reloadCache();
        return Results.success("加载缓存成功");
    }

    @DeleteMapping("/clear")
    public ResponseEntity<String> removeCache() {
        knifeCacheV2Service.removeCache();
        return Results.success("清空缓存成功");
    }
}
